 

function monthCheckCtrl($scope, $http, ngDialog, ngDialogProblem) {
  'ngInject';

  this.orgId = $state.params.orgId;
  this.bidId = $state.params.bidId;

  this.queryData = {
    queryType: 0, // pc:0,app:1
    status: 99, // 已完成
  };

  if (this.orgId) {
    this.queryData.orgId = this.orgId;
  } else if (this.bidId) {
    this.queryData.bidId = this.bidId;
  }

  this.dailyCheckList = {};

  // 不显示内容详细列表
  this.showDetailList = false;

  // 分页
  this.paginationData = {
    pageNum: 0,
    pageSize: 5,
    total: '',
  }

  // 页码变化时调用方法
  $scope.pageChange = () => {
    
    this.paginationData1 = {
      pageNum: this.paginationData.pageNum-1,
      pageSize: 5,
      total: '',
    }

    $http.post(`${SERVER_CONTEXT}/api/checkRecord/app/queryDailyCheckByCondition`,
      angular.extend(this.queryData, this.paginationData1)
        )
      .then((resp) => {       
        this.dailyCheckList = resp.data.data;
        this.paginationData.total = resp.data.total;               
    });
  };

  // 分页查询方法
  this.paginationQuery = () => {
    this.showDetailList = false;
    $http.post(`${SERVER_CONTEXT}/api/checkRecord/app/queryDailyCheckByCondition`,
      angular.extend(this.queryData, this.paginationData)
        )
      .then((resp) => {       
        this.dailyCheckList = resp.data.data;
        this.paginationData.total = resp.data.total;               
    });

  };  

  // 查询
  this.query = (param) => {
    // 问题处理状态   
    if (this.problemStatus == 3) {  
      this.queryData.taskStatusList=[];   
      this.queryData.taskStatusList.push(3);
    } else if (this.problemStatus == 1) {
      this.queryData.taskStatusList=[];      
      this.queryData.taskStatusList.push(0,1,2);
    } else {
      this.queryData.taskStatusList=[];
    }
    // 巡查开始时间大小判断
    if(param.endTime.$viewValue && param.startTime.$viewValue){
      if (param.startTime.$viewValue < param.endTime.$viewValue) {
        this.paginationQuery();
    } else {
        layer.alert('巡查开始时间应小于结束时间');
      }
    } else {
      this.paginationQuery();
    } 

  } 

  // 重置
  this.reset = () => {
    this.queryData = {
      queryType: 0,
    };
  }

  // 显示巡查内容
  this.showDetail = (id) => {
    this.showDetailList = true;
    $http
      .get(`${SERVER_CONTEXT}/api/checkRecord/app/queryContentList/${id}`,{})
      .then((resp) => {
        this.dailyCheckDetailList = resp.data;
        document.getElementById('check_list').scrollIntoView();      
    });
  }

  // 查看内容详情
  this.checkDetail = (item) => {
    ngDialogProblem
      .confirm(item.problemId)
      .then((data) => {
        this.paginationQuery();
        this.showDetail(item.taskId);
      });
  }

  // 升序、降序（参数没定）
  this.up = (param,index) => {   
    this.queryData.columeName = param;
    this.queryData.order = index;
    this.paginationQuery();
  }

  this.initPage = () => {
    // 获取巡查列表
    this.paginationQuery();
  }

  // 初始化
  this.initPage();

}

export default monthCheckCtrl;